import { createStore, Store, useStore as useVuexStore } from "vuex";
import { IRootState, IStoreType } from "./types";
import login from "./login/login";
import system from "./main/system/system";
import product from "./main/product/product";
import echartsData from "./main/index/echartData";
import goods from "./main/goods/goods";
import category from "./main/category/category";
const store = createStore<IRootState>({
  // 利用接口(泛型)来指定类型
  state: () => {
    return {
      name: "coderwhy",
      age: 18
    };
  },
  mutations: {
    changeName(state) {
      // console.log(state);
    }
  },
  getters: {},
  actions: {},
  modules: {
    login,
    system,
    product,
    echartsData,
    goods,
    category
  }
});

export function useStore(): Store<IStoreType> {
  return useVuexStore();
}

export default store;
